﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongMamNon.Man_Hinh
{
    public partial class frmBai_Hoc : Form
    {
        public frmBai_Hoc()
        {
            InitializeComponent();
        }

        public DataTable DocBangKhoi()
        {
            string sql = "select * from Khoi";
            DataTable dt = new DataTable();
            dt = Thu_Vien.ExecuteQuery(sql);
            return dt;
        }

        public DataTable DocMon(string strMaKhoi)
        {
            string sql = "select * from Mon_Hoc where MaKhoi=' " + strMaKhoi + "'";
            DataTable dt = new DataTable();
            dt = Thu_Vien.ExecuteQuery(sql);
            return dt;
        }

        public DataTable DocBaiHoc(string strMaMon)
        {
            string sql = "select * from Bai_Hoc where MaMon=' " + strMaMon + "'";
            DataTable dt = new DataTable();
            dt = Thu_Vien.ExecuteQuery(sql);
            return dt;
        }

        public void HienThiKhoi()
        {
            cboKhoi.DataSource = DocBangKhoi();
            cboKhoi.DisplayMember = "Tenkhoi";
        }

        public void HienThiMonHoc()
        {
            //if (cboKhoi.se
           // {
            //    dtgMon.DataSource = null;
           // }
           // else
            //{
                dtgMon.DataSource = DocMon(cboKhoi.Text);
            //}

        }
        public void HienThiBaiHoc()
        {
            //if (dtgMon.RowCount()=0)
            //{
             //   dtgBaiHoc.DataSource = null;
           // }
           // else
            //{
               // dtgBaiHoc.DataSource = DocBaiHoc(dtgMon.SelectedRows());
           // }

        }

        private void frmBai_Hoc_Load(object sender, EventArgs e)
        {
            HienThiKhoi();
           // HienThiMonHoc();
           // HienThiBaiHoc();

        }
    }
}
